#include <iostream>
#include <cstring>
using namespace std;
const int N = 1050;
int n, m;
int g[N][N]; // 邻接矩阵 用来存储图
int dist[N]; // 每个点到集合的距离
bool st[N];  // 标记这个点是否被加载到集合中 

void prime(){
	memset(dist, 0x3f, sizeof dist);
	for (int i = 0; i < n; i++){
		int t = -1;
		for (int j = 1; j <= n; j++){
			if (!st[j] && (t == -1 || dist[t] > dist[j])){ t = j;}
		}
		st[t] = true;
		for (int j = 1; j <= n; j++){
			dist[j] = min(dist[j], dist[t]);
		}
	}
}

int main(){
	cin >> n >> m;
	while (m--) {
		int a, b, w;
		cin >> a >> b >> w;
	}
}
